package queues;

import java.util.ArrayList;

public class PostOfficeQueueSimulator{

	private ArrayList<Person> queue;
	
	public PostOfficeQueueSimulator() {
		queue = new ArrayList<Person>();
	}
	
	public void addPerson(Person p) {
		queue.add(p);
	}
	
	public void serve() {
		if (!queue.isEmpty())
			queue.remove(0);
	}
	
	public int queueLength() {
		return queue.size();
	}
	
	public void printQueue() {
		for (Person p : queue) {
			p.print();
			System.out.println(".");
		}
	}
	
	public void whoseAt(int x) {
		if (x < queue.size()) {
			queue.get(x).print();
			System.out.println(" is at position " + x + ".");
		}
	}
	
	public void whoseAtFront() {
		if (!queue.isEmpty()) {
			queue.get(0).print();
			System.out.println(" is at the front of the queue.");
		}
	}
}
